export default {
    getExportData(myself, dataname, columns) {
        let datas = myself[dataname];
        let headers = [columns.map(item => item.title)];
        return headers.concat(
            datas.map(row => {
                return columns.map(column => {
                    switch (column.property) {
                        case "emer_flag":
                            return row[column.property] == "1" ? "急" : "";
                        case "pat_sex":
                            if (!row[column.property]) {
                                return "";
                            } else {
                                return row[column.property] == "1" ? "男" : "女";
                            }
                        case "cp_itemState":
                            if (!row.cp_itemState) {
                                return row.cp_itemnames;
                            } else {
                                return row.cp_itemnames_mx;
                            }
                        default:
                            return row[column.property];
                    }
                });
            })
        );
    },
    toBuffer(wbout) {
        let buf = new ArrayBuffer(wbout.length);
        let view = new Uint8Array(buf);
        for (let index = 0; index !== wbout.length; ++index) view[index] = wbout.charCodeAt(index) & 0xff;
        return buf;
    },
}